package com.jt.dify.config;

import org.noear.solon.ai.chat.ChatConfig;
import org.noear.solon.ai.chat.ChatModel;
import org.noear.solon.ai.chat.dialect.ChatDialectManager;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;

/**
 * @author by HaiTao.Wang on 2025/3/05.
 */

@Configuration
public class AIConfig {

    @Bean
    public ChatModel build(@Inject("${solon.ai.dify}") ChatConfig config) {

        ChatDialectManager.register(new DifyChatDialect());

        return ChatModel.of(config.getApiUrl())
                .headerSet("Authorization", "Bearer ".concat(config.getApiKey()))
                .provider(config.getProvider())
                .build();
    }


}
